#include "projectile.h"

Projectile::Projectile(const Vect2D& start_position, const Vect2D& start_speed, SDL_Surface* proj_sprite, int damage, double size) : Object()
{
	position = start_position;
	speed = start_speed;
	border = size;
	sprite = proj_sprite;
	explode = false;
	remove = false;
	health = damage;

	src_rect.x = 0;
	src_rect.y = 0;
	src_rect.w = 10;
	src_rect.h = 10;
}

void Projectile::Frame_calculate()
{
	if(speed.Get_lenght() < 10)
	{
		explode = true;
	}
	// animation of object exploding, when eplode is set off by collision, or slow movement
	if(explode)
	{
		src_rect.y += src_rect.h;
		if(src_rect.y >= sprite->h)
			remove = true;
	}

	speed = speed * 0.9;

}

int Projectile::Hit()
{
	Set_remove();
	//speed = 0;
	return health;
}

void Projectile::Set_remove()
{
	explode = true;
}
